package com.zyf.spit.dao;

import com.zyf.spit.pojo.Comment;
import com.zyf.spit.utils.Mongodb;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;

@Component
public class CommentDao {
    @Autowired
    Mongodb mongodb;

    public void add(Comment comment) {
        mongodb.insert(comment);
    }

    public void delete(String id){
        mongodb.delete(id);
    }
    public List<String> findContentByArticleId(String articleid) {
        List<Comment> list = (List<Comment>) mongodb.select("articleid", articleid);
        List list1=new ArrayList();
        for (Comment c:list) {
            list1.add(c.getContent());
        }
        return list1;
    }
}
